import java.util.LinkedList;
import java.util.Scanner;

public class FrontDeskReception extends Users implements LogIn {
    public FrontDeskReception(){}
    public FrontDeskReception(String ID,String name,String password,String registrationDate,String role,String phoneNumber){
        super(ID,name,password,registrationDate,role,phoneNumber);
    }

    //登录前台的用户名和密码
    @Override
    public boolean logIn(String name, String password) {
        CinemaSystem cinemaSystem = CinemaSystem.getInstance();
        for (FrontDeskReception front : cinemaSystem.getFrontDeskReceptionList()) {
            if (front.getName().equals(name) && front.getPassword().equals(password)) {
                return true;
            }
        }
        return false;
    }
    //重写接口
    //没用
    public void changePassword(String newPassword) {

    }

    //没用
    @Override
    public void resetPassword() {

    }
    //重写父类中的方法
    @Override
    public void listAllUsers() {
        // 获取CinemaSystem中的前台用户列表
        LinkedList<FrontDeskReception> frontDeskList = CinemaSystem.getInstance().getFrontDeskReceptionList();
        if (frontDeskList.isEmpty()) {
            System.out.println("当前没有前台用户信息！");
            return;
        }
        System.out.println("\n=== 前台用户列表 ===");
        System.out.println("ID\t姓名\t注册日期\t\t电话");
        for (FrontDeskReception user : frontDeskList) {
            System.out.printf("%s\t%s\t%s\t%s\n", user.getID(), user.getName(), user.getRegistrationDate(), user.getPhoneNumber());
        }
    }

    // 添加电影场次及座位信息查询方法
    public static void listMovieSessionsWithSeats(String movieName) {
        LinkedList<Session> sessions = Session.getSessionList();

        if (sessions.isEmpty()) {
            System.out.println("当前没有任何场次信息");
            return;
        }

        boolean found = false;
        for (Session s : sessions) {
            if (s.getMovieName().equals(movieName)) {
                found = true;
                System.out.println("\n======================================");
                System.out.println("           场次详细信息");
                System.out.println("======================================");
                System.out.printf("影片名称：%s\n", s.getMovieName());
                System.out.printf("放映时间：%s - %s\n", s.getStartTime(), s.getEndTime());
                System.out.printf("放映厅：%s\n", s.getHallName());
                System.out.printf("票价：%.2f元\n", s.getPrice());

                // 获取该场次的座位信息
                SeatsForSession seats = SeatsForSession.getSeatsBySession(s);
                if (seats != null) {
                    System.out.printf("总座位数%d\n", seats.getTotalSeats());
                    System.out.printf("空闲座位数：%d\n", seats.getFreeSeats());
                    System.out.println("\n座位布局\n");
                    seats.displaySeatMap(); // 显示座位图
                } else {
                    System.out.println("未找到该场次的座位信息");
                }
                System.out.println("======================================\n");
            }
        }

        if (!found) {
            System.out.println("未找到名称为《" + movieName + "》的影片场次");
        }
    }


    //没用
    @Override
    public void deleteUser() {

    }
    //没用
    @Override
    public void searchUser() {

    }
    //没用
    @Override
    public void addUser() {

    }
    //没用
    @Override
    public void modifyUser() {

    }
}
